package com.EpidemicPrevention.service;

import com.EpidemicPrevention.mapper.EnrolledMapper;
import com.EpidemicPrevention.pojo.Enrolled;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class EnrolledServiceImpl implements EnrolledService{
    @Autowired
    private EnrolledMapper enrolledMapper;

    @Override
    public JSON addEnrolled(Enrolled enrolled) {
        JSONObject json = new JSONObject();
        int code =0;
        code = enrolledMapper.addEnrolled(enrolled);
        if (code ==1){
            json.put("msg","添加成功");
            json.put("code",1);
        }else {
            json.put("msg","添加失败");
            json.put("code",0);
        }
        return json;
    }

    @Override
    public JSON deleteEnrolled(int e_id) {
        JSONObject json = new JSONObject();
        int code =0;
        code = enrolledMapper.deleteEnrolled(e_id);
        if (code ==1){
            json.put("msg","删除成功");
            json.put("code",1);
        }else {
            json.put("msg","删除失败");
            json.put("code",0);
        }
        return json;
    }

    @Override
    public JSON updateEnrolled(Enrolled enrolled) {
        JSONObject json = new JSONObject();

            int code=0;
            code=enrolledMapper.updateEnrolled(enrolled);
            if (code==1){
                json.put("msg","修改入校信息成功");
                json.put("code",1);
            }else{
                json.put("msg","修改入校信息失败");
                json.put("code",0);
            }

        return json;
    }

    @Override
    public List<Enrolled>  queryEnrolled (int page, int limit,String Keyword) {
        return enrolledMapper.queryEnrolled(page, limit,null);
    }

    @Override
    public List<Enrolled> selectWhereEnrolled() {
        return enrolledMapper.selectWhereEnrolled();
    }





}
